package com.bbf.mathgen.service;

/**
 * 算术符号枚举
 * @author BBF
 */
public enum MathEnum {
  /**
   * 错误类型，-1
   */
  undefine(-1, "未定义"),

  plus(0, "＋"),
  minus(1, "－");

  private final int code;
  private final String msg;

  MathEnum(int code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  public int getCode() {
    return code;
  }

  public String getMsg() {
    return msg;
  }

  /**
   * 根据枚举编码，获取枚举值
   * @param code 枚举编码
   * @return 枚举值
   */
  public static MathEnum getByCode(int code) {
    for (MathEnum st : values()) {
      if (code == st.getCode()) {
        return st;
      }
    }
    return undefine;
  }
}
